using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace CodeSyntaxHighLighter.Controls
{
	public class ColorPicker : Control
	{
		ColorDialog _dialog = new ColorDialog();
		public ColorPicker()
		{
			Panel p = new Panel();
			p.BorderStyle = BorderStyle.FixedSingle;
			p.Dock = DockStyle.Fill;
			this.Controls.Add(p);
			p.BackColor = Color.Transparent;

			this.Cursor = Cursors.Hand;
			p.Click += new EventHandler(ColorPicker_Click);
			this.BackColor = ColorTranslator.FromHtml("#F7F7FF");
		}

		public string HtmlColor
		{
			get { return ColorTranslator.ToHtml(this.BackColor); }
			set { this.BackColor = ColorTranslator.FromHtml(value); }
		}

		void ColorPicker_Click(object sender, EventArgs e)
		{
			_dialog.Color = this.BackColor;
			if (DialogResult.OK == _dialog.ShowDialog())
			{
				this.BackColor = _dialog.Color;
			}
		}
	}
}
